﻿//
// ApplicationSettings.cs: General settings for the S9Pal application.
//
// Copyright 2010 Michael Goethe
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using S9PalCommon;

namespace S9Pal
{
    /// <summary>
    /// General settings for the S9Pal application.
    /// </summary>
    [Serializable]
    public sealed class ApplicationSettings : Settings
    {
        #region Fields

        private Size windowSize;
        private FormWindowState windowState;
        private Dictionary<String, bool> pluginComponentEnabled;
        private DirectoryInfo customLibraryDirectory = null;
        private bool pullLibraryFromDevice = true;

        #endregion

        #region Constructors

        public ApplicationSettings() : base("ApplicationSettings.dat")
        {

        }

        #endregion

        #region Properties

        public DirectoryInfo CustomLibraryDirectory
        {
            get
            {
                return customLibraryDirectory;
            }
            set
            {
                customLibraryDirectory = value;
            }
        }

        /// <summary>
        /// Dictionary of plugin types and their enabled statuses.
        /// </summary>
        public Dictionary<String, bool> PluginComponentEnabled
        {
            get
            {
                if (pluginComponentEnabled == null)
                    pluginComponentEnabled = new Dictionary<String, bool>();

                return pluginComponentEnabled;
            }
            set
            {
                pluginComponentEnabled = value;
            }
        }

        public bool PullLibraryFromDevice
        {
            get
            {
                return pullLibraryFromDevice;
            }
            set
            {
                pullLibraryFromDevice = value;
            }
        }

        /// <summary>
        /// Size of the main window.
        /// </summary>
        public Size WindowSize
        {
            get
            {
                return windowSize;
            }
            set
            {
                windowSize = value;
            }
        }

        /// <summary>
        /// State of the main window.
        /// </summary>
        public FormWindowState WindowState
        {
            get
            {
                return windowState;
            }
            set
            {
                windowState = value;
            }
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// Set the settings to their defaults.
        /// </summary>
        protected override void OnDefault()
        {
            windowSize = new Size(640, 480);
            windowState = FormWindowState.Normal;
        }

        #endregion
    }
}
